import request from '../utils/request'
export const getArticleDetailAPI = (id) => {
  return request.get(`/v1_0/articles/${id}`)
}

// 关注作者的api接口
export const followUserApi = (target) => {
  return request.post('/v1_0/user/followings', { target })
}

// 取消关注作者的api接口
export const unfollowUserAPI = (id) => {
  return request.delete(`/v1_0/user/followings/${id}`)
}

// 点赞的api
export const addLikeAPI = (target) => {
  return request.post('/v1_0/article/likings', { target })
}
// 取消点赞
// id为文章的id
export const delLikeAPI = (id) => {
  return request.delete(`/v1_0/article/likings/${id}`)
}

// 根据文章id请求文章下评论的接口
export const getCmtListAPI = (source, offset) => {
  return request.get('/v1_0/comments', {
    params: {
      type: 'a',
      source,
      offset
    }
  })
}

export const publishCommentAPI = (target, content) => {
  return request.post('/v1_0/comments', { target, content })
}

export const commentLiking = (target) => {
  return request.post('/v1_0/comment/likings', {
    target
  })
}

export const commentDelLiking = (id) => {
  return request.delete(`/v1_0/comment/likings/${id}`)
}
